#!/bin/bash 

#目录创建
# 定义要检查的路径  

minioM=1.92.154.87
minioS=124.70.14.42
minioUserName=minioAdmin
minioPassword=minio_123456.
minioPath=/home/minio/data/
sudo rm -rf $minioPath
# 检查路径是否存在  
if [ ! -d $minioPath ]; then  
  # 路径不存在，创建它  
  sudo mkdir -p $minioPath  
  sudo chmod +x $minioPath
  echo "目录 '$minioPath' 已创建。"  
else  
  echo "目录 '$minioPath' 已存在。"
fi
docker load --input ../bin/minio.tar
sudo docker run -d -p 9000:9000 -p 9001:9001  -e "MINIO_ACCESS_KEY=minioadmin" -e "MINIO_SECRET_KEY=minioadmin" --name minio --restart=always minio/minio:latest server  D:\aEnverimentAndSDKs\Minio\data --console-address ":9001"
 
sleep 1

sudo chmod +x ../bin/mc

echo "安装mc 服务..."
cp ../bin/mc /usr/bin/
cp ./mc.service /usr/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable mc
sudo systemctl start mc

mc config host add minio http://127.0.0.1:9000 $minioUserName $minioPassword
mc mb minio/customfile
mc anonymous set public minio/customfile
#添加主从同步
#mc config host add minio_master http://$minioM:9000 $minioUserName $minioPassword
#mc config host add minio_slave http://$minioS:9000 $minioUserName $minioPassword
